/**
 * $Id: MessageConvertor.java,v 1.8 2006/06/21 11:39:38 star Exp $
 *
 * Copyright 2006 Skyinfo, Inc. All Rights Reserved.
 */
package com.haoxi.gateway.messageconvertor;

import com.haoxi.gateway.common.CommonMsgBean;
import com.haoxi.gateway.runner.smscommand.BaseCommandObj;

/**
 * TODO
 * 
 * Revision History
 *
 * 2006-5-25,star.Zhao,created it
 */
public abstract class MessageConvertor {
    protected String gatewayCode;
    
    public MessageConvertor(String gatewayCode){
        this.gatewayCode = gatewayCode;
    }
    
    private final Object syn_sequence_obj = new Object();
    private int sequence;
    /**
     * get sequence
     * @param
     * @return sequence
     */
    public int getSequence()
    {
        synchronized(syn_sequence_obj) {
            sequence++;
            if (sequence > 0x7fffffff)
                sequence = 0;
            return sequence;
        }
    }
    
    /**
     * 对命令进行转换为统一的CommonMsgBean
     * @param obj
     * @return
     */
    public abstract CommonMsgBean convertCMDToCommonMsg(BaseCommandObj obj);
    
    /**
     * 对CommonMsgBean进行转换为统一的命令
     * @param obj
     * @return
     */
    public abstract BaseCommandObj convertCommonMsgToCMD(CommonMsgBean commonMsgBean);
    
}
